@extends('layouts.admin.application')

@section('css')
    <link rel="stylesheet" href="/ace/assets/css/daterangepicker.css">
@endsection

@section('content')
    <div class="main-content">
        <div class="col-xs-12">
            <div class="breadcrumbs" id="breadcrumbs">
                <ul class="breadcrumb">
                    <li><i class="icon-home home-icon"></i><a href="#">首页</a></li>
                    <li>会员管理</li>
                </ul>
            </div>

            @include('layouts.partials._flash')

            <div class="table-responsive">
                <div id="sample-table-2_wrapper" class="dataTables_wrapper" role="grid">
                    <div class="row">
                        <form>
                            <div class="dataTables_filter" id="sample-table-2_filter">
                                <label>会员昵称: <input type="text" name="nickname" value="{{Request::input('nickname')}}"
                                                    aria-controls="sample-table-2"
                                                    placeholder="按昵称"></label>
                                <label>
                                    <select class="dataTables_filter" name="sex" style="width: 180px;">
                                        <option value="-1" @if(Request::input('sex') == '-1') selected @endif>选择性别
                                        </option>
                                        <option value="1" @if(Request::input('sex') == '1') selected @endif>男</option>
                                        <option value="0" @if(Request::input('sex') == '0') selected @endif>女</option>
                                    </select>
                                </label>
                                <label>注册日期: <input type="text" name="created_at" id="created_at"
                                                    aria-controls="sample-table-2" style="width: 174px;"
                                                    placeholder="选择时间日期" value="{{ Request::input('created_at') }}">
                                </label>
                                <label>
                                    <button type="submit" class="btn btn-xs btn-info" id="search">确定</button>
                                    <a href="{{route('shop.customer.index')}}" class="btn btn-xs btn-default">重置</a>
                                </label>
                            </div>
                        </form>
                    </div>
                    <table id="sample-table-2"
                           class="table table-striped table-bordered table-hover dataTable del-table"
                           aria-describedby="sample-table-2_info">
                        <thead>
                        <tr role="row">
                            <th>编号</th>
                            <th>会员头像</th>
                            <th>昵称</th>
                            <th>openid</th>
                            <th>性别</th>
                            <th>关注时间</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>

                        @foreach($customers as $customer)
                            <tr class="odd">
                                <td>{{$customer->id}}</td>
                                <td><img src="{{$customer->headimgurl}}" style="width: 40px;height: 35px;"></td>
                                <td>{{ $customer->nickname }}</td>
                                <td>{{$customer->openid}}</td>
                                <td>
                                    @if($customer->sex == 1)
                                        <span class="label label-purple arrowed-in-right arrowed">男</span>
                                    @else
                                        <span class="label label-pink arrowed-in-right arrowed">女</span>
                                    @endif
                                </td>
                                <td>{{$customer->created_at}}</td>
                                <td>
                                    <a href="/admin/shop/order?customer_id={{ $customer->id }}"
                                       class="btn btn-minier btn-yellow">查看订单</a>
                                </td>
                            </tr>
                        @endforeach

                        </tbody>
                    </table>
                    <div class="row">
                        <div class="col-sm-6">共 {{$customers->total()}} 条记录</div>
                        <div class="col-sm-6">
                            <div class="dataTables_paginate paging_bootstrap">
                                <ul class="pagination">
                                    {{ $customers->appends(Request::all())->links() }}
                                </ul>
                            </div>
                        </div>
                    </div>

                </div>
            </div>
        </div>
    </div>
@endsection

@section('js')
    <script src="/ace/assets/js/date-time/daterangepicker.min.js"></script>
    <script src="/ace/assets/js/date-time/moment.min.js"></script>
    <script>
        $(function () {
            //时间插件
            $('#created_at').daterangepicker({
                "locale": {
                    "applyLabel": "确定",
                    "cancelLabel": "取消"
                }
            });
        })
    </script>
@endsection
